package com.shahe.GirlsDay.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.shahe.GirlsDay.LogActivity;
import com.shahe.GirlsDay.R;
import com.shahe.GirlsDay.util.StaticClass;

public class EventFragment extends Fragment {

	private ImageButton iButton_su;
	public static int flag_su = 0;
	private ImageButton iButton_b;
	public static int flag_b = 0;
	private ImageButton iButton_cf;
	public static int flag_cf = 0;
	private ImageButton iButton_sf;
	public static int flag_sf = 0;
	private ImageButton iButton_ff;
	public static int flag_ff = 0;
	private ImageButton iButton_ct;
	public static int flag_ct = 0;
	private ImageButton iButton_ex;
	public static int flag_ex = 0;
	private ImageButton iButton_hw;
	public static int flag_hw = 0;
	private ImageButton iButton_d;
	public static int flag_d = 0;
	private ImageButton iButton_kk;
	public static int flag_kk = 0;
	private ImageButton iButton_sh;
	public static int flag_sh = 0;
	private ImageButton iButton_par;
	public static int flag_par = 0;
	private ImageButton iButton_et;
	public static int flag_et = 0;

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.log_event, null);

		iButton_su = (ImageButton) view.findViewById(R.id.ibtn_log_event_su);
		if (LogActivity.oneDayInfo.getStayUp().equals("1")) {
			iButton_su.setBackgroundResource(R.drawable.su2);
		}
		iButton_su.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_su % 2 == 0) {
					iButton_su.setBackgroundResource(R.drawable.su2);
					flag_su++;

				} else {
					iButton_su.setBackgroundResource(R.drawable.su);
					flag_su++;
				}
				// StaticClass.event_su = flag_su % 2;
			}
		});

		iButton_b = (ImageButton) view.findViewById(R.id.ibtn_log_event_b);
        if (LogActivity.oneDayInfo.getBath().equals("1")) {
            iButton_b.setBackgroundResource(R.drawable.b2);
        }
		iButton_b.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_b % 2 == 0) {
					iButton_b.setBackgroundResource(R.drawable.b2);
					flag_b++;
				} else {
					iButton_b.setBackgroundResource(R.drawable.b);
					flag_b++;
				}
				// StaticClass.event_b = flag_b % 2;
			}
		});

		iButton_cf = (ImageButton) view.findViewById(R.id.ibtn_log_event_cf);
        if (LogActivity.oneDayInfo.getColdFood().equals("1")) {
            iButton_cf.setBackgroundResource(R.drawable.cf2);
        }
		iButton_cf.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_cf % 2 == 0) {
					iButton_cf.setBackgroundResource(R.drawable.cf2);
					flag_cf++;
				} else {
					iButton_cf.setBackgroundResource(R.drawable.cf);
					flag_cf++;
				}
				// StaticClass.event_cf = flag_cf % 2;
			}
		});

		iButton_sf = (ImageButton) view.findViewById(R.id.ibtn_log_event_sf);
        if (LogActivity.oneDayInfo.getSpicyFood().equals("1")) {
            iButton_sf.setBackgroundResource(R.drawable.sf2);
        }
		iButton_sf.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_sf % 2 == 0) {
					iButton_sf.setBackgroundResource(R.drawable.sf2);
					flag_sf++;
				} else {
					iButton_sf.setBackgroundResource(R.drawable.sf);
					flag_sf++;
				}
				// StaticClass.event_sf = flag_sf % 2;
			}
		});

		iButton_ff = (ImageButton) view.findViewById(R.id.ibtn_log_event_ff);
        if (LogActivity.oneDayInfo.getFriedFood().equals("1")) {
            iButton_ff.setBackgroundResource(R.drawable.ff2);
        }
		iButton_ff.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_ff % 2 == 0) {
					iButton_ff.setBackgroundResource(R.drawable.ff2);
					flag_ff++;
				} else {
					iButton_ff.setBackgroundResource(R.drawable.ff);
					flag_ff++;
				}
				// StaticClass.event_ff = flag_ff % 2;
			}
		});

		iButton_ct = (ImageButton) view.findViewById(R.id.ibtn_log_event_ct);
        if (LogActivity.oneDayInfo.getCoffeeTea().equals("1")) {
            iButton_ct.setBackgroundResource(R.drawable.ct2);
        }
		iButton_ct.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_ct % 2 == 0) {
					iButton_ct.setBackgroundResource(R.drawable.ct2);
					flag_ct++;
				} else {
					iButton_ct.setBackgroundResource(R.drawable.ct);
					flag_ct++;
				}
				// StaticClass.event_ct = flag_ct % 2;
			}
		});

		iButton_ex = (ImageButton) view.findViewById(R.id.ibtn_log_event_ex);
        if (LogActivity.oneDayInfo.getExercise().equals("1")) {
            iButton_ex.setBackgroundResource(R.drawable.ex2);
        }
		iButton_ex.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_ex % 2 == 0) {
					iButton_ex.setBackgroundResource(R.drawable.ex2);
					flag_ex++;
				} else {
					iButton_ex.setBackgroundResource(R.drawable.ex);
					flag_ex++;
				}
				// StaticClass.event_ex = flag_ex % 2;
			}
		});

		iButton_hw = (ImageButton) view.findViewById(R.id.ibtn_log_event_hw);
        if (LogActivity.oneDayInfo.getHeavyWork().equals("1")) {
            iButton_hw.setBackgroundResource(R.drawable.hw2);
        }
		iButton_hw.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_hw % 2 == 0) {
					iButton_hw.setBackgroundResource(R.drawable.hw2);
					flag_hw++;
				} else {
					iButton_hw.setBackgroundResource(R.drawable.hw);
					flag_hw++;
				}
				// StaticClass.event_hw = flag_hw % 2;
			}
		});

		iButton_d = (ImageButton) view.findViewById(R.id.ibtn_log_event_d);
        if (LogActivity.oneDayInfo.getDrink().equals("1")) {
            iButton_d.setBackgroundResource(R.drawable.d2);
        }
		iButton_d.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_d % 2 == 0) {
					iButton_d.setBackgroundResource(R.drawable.d2);
					flag_d++;
				} else {
					iButton_d.setBackgroundResource(R.drawable.d);
					flag_d++;
				}
				// StaticClass.event_d = flag_d % 2;
			}
		});

		iButton_kk = (ImageButton) view.findViewById(R.id.ibtn_log_event_kk);
        if (LogActivity.oneDayInfo.getKaraoke().equals("1")) {
            iButton_kk.setBackgroundResource(R.drawable.kk2);
        }
		iButton_kk.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_kk % 2 == 0) {
					iButton_kk.setBackgroundResource(R.drawable.kk2);
					flag_kk++;
				} else {
					iButton_kk.setBackgroundResource(R.drawable.kk);
					flag_kk++;
				}
				// StaticClass.event_kk = flag_kk % 2;
			}
		});

		iButton_sh = (ImageButton) view.findViewById(R.id.ibtn_log_event_sh);
        if (LogActivity.oneDayInfo.getShopping().equals("1")) {
            iButton_sh.setBackgroundResource(R.drawable.sh2);
        }
		iButton_sh.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_sh % 2 == 0) {
					iButton_sh.setBackgroundResource(R.drawable.sh2);
					flag_sh++;
				} else {
					iButton_sh.setBackgroundResource(R.drawable.sh);
					flag_sh++;
				}
				// StaticClass.event_sh = flag_sh % 2;
			}
		});

		iButton_par = (ImageButton) view.findViewById(R.id.ibtn_log_event_par);
        if (LogActivity.oneDayInfo.getParty().equals("1")) {
            iButton_par.setBackgroundResource(R.drawable.par2);
        }
		iButton_par.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_par % 2 == 0) {
					iButton_par.setBackgroundResource(R.drawable.par2);
					flag_par++;
				} else {
					iButton_par.setBackgroundResource(R.drawable.par);
					flag_par++;
				}
				// StaticClass.event_par = flag_par % 2;
			}
		});

		iButton_et = (ImageButton) view.findViewById(R.id.ibtn_log_event_et);
        if (LogActivity.oneDayInfo.getExtractTooth().equals("1")) {
            iButton_et.setBackgroundResource(R.drawable.et2);
        }
		iButton_et.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				if (flag_et % 2 == 0) {
					iButton_et.setBackgroundResource(R.drawable.et2);
					flag_et++;
				} else {
					iButton_et.setBackgroundResource(R.drawable.et);
					flag_et++;
				}
				// StaticClass.event_et = flag_et % 2;
			}
		});

		return view;
	}
}
